package com.chenfan.finance.utils;

import com.github.pagehelper.PageInfo;
import org.springframework.beans.BeanUtils;

import java.util.List;

/**
 * @author: xuxianbei
 * Date: 2020/8/31
 * Time: 14:49
 * Version:V1.0
 */
public class PageInfoUtil {


    /**
     * 类型转换
     * @param totalList  从数据库中拿到的list
     * @param volist  返回界面的list
     * @param <T>
     * @return
     */
    public static <T> PageInfo<T> toPageInfo(List<?> totalList, List<T> volist) {
        PageInfo<T> resultPageInfo = new PageInfo(volist);
        PageInfo old = new PageInfo<>(totalList);
        BeanUtils.copyProperties(old, resultPageInfo);
        resultPageInfo.setList(volist);
        resultPageInfo.setTotal(old.getTotal());
        return resultPageInfo;
    }
}
